import { defineMock } from "../base";

export default defineMock([
  // POST uri: /api/npi/{cpu}/1 用户数据清零
  {
    url: "npi/:cpu/1",
    method: ["POST"],
    body({ query, params }) {
      console.log("[MOCK] POST npi/:cpu/1 (用户数据清零)", query, params);
      
      const cpu = parseInt(params.cpu);
      
      // 模拟成功响应
      return {
        cpu,
        status: "Success",
      };
    },
  },

  // POST uri: /api/npi/{cpu}/2 NPI 数据清零
  {
    url: "npi/:cpu/2",
    method: ["POST"],
    body({ query, params }) {
      console.log("[MOCK] POST npi/:cpu/2 (NPI 数据清零)", query, params);
      
      const cpu = parseInt(params.cpu);
      
      // 模拟成功响应
      return {
        cpu,
        status: "Success",
      };
    },
  },

  // POST uri: /api/npi/{cpu}/{type} 通用数据清零（兼容旧版本）
  {
    url: "npi/:cpu/:type",
    method: ["POST"],
    body({ query, params }) {
      console.log("[MOCK] POST npi/:cpu/:type (通用数据清零)", query, params);
      
      const cpu = parseInt(params.cpu);
      const type = parseInt(params.type);
      
      // 验证类型参数
      if (type !== 1 && type !== 2) {
        return {
          cpu,
          status: "Error",
          message: "无效的清零类型，type 必须为 1 (用户数据) 或 2 (NPI 数据)",
        };
      }
      
      // 模拟成功响应
      return {
        cpu,
        status: "Success",
      };
    },
  },
]);
